package org.hard.model.create.abstractFactory.product;


/**
 *
 * 客户端代码仅通过抽象类型（GUIFactory、Button 和 Checkbox）使用工厂和产品。
 * 这让你无需修改任何工厂或产品子类就能将其传递给客户端代码。
 * @author: 王林博
 * @date: 2023年02月10日 11:32
 */
public class Application {

//    @Autowired
    private static WinFactory factory = new WinFactory();

    public GUIFactory guiFactory;
    public Button button;
    public Checkbox checkbox;

    public Application(GUIFactory guiFactory){
        this.guiFactory = guiFactory;
    }

    public void createUI(){
        this.button = guiFactory.createButton();
        this.checkbox = guiFactory.createCheckbox();
    }

    public void createCheckbox(){
        this.button = guiFactory.createButton();
        this.checkbox = guiFactory.createCheckbox();
    }

    public void paint(){
        this.button.paint();
        this.checkbox.paint();
    }

    public static void main(String[] args) {
        Application application = new Application(factory);
        application.createCheckbox();
        application.paint();

    }
}
